@extends('layouts.app')
@section('content')
    @include('UEditor::head');
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">发布问题</div>

                    <div class="card-body">
                        @if (session('status'))
                            <div class="alert alert-success">
                                {{ session('status') }}
                            </div>
                        @endif
                        <!-- 加载编辑器的容器 -->
                            <form action="/questions" method="post">
                                {{csrf_field()}}
                                <div class="form-group">
                                    <label for="title">标题</label>
                                    <input type="text" name="title" value="{{old('title')}}" class="form-control {{ $errors->has('title') ? ' is-invalid' : '' }}" placeholder="标题">
                                    @if ($errors->has('title'))
                                        <span class="invalid-feedback">
                                        <strong>{{ $errors->first('title') }}</strong>
                                    </span>
                                    @endif
                                </div>
                                <script id="container"  name="body" type="text/plain">
                                    {!! old('body') !!}
                                </script>
                                @if ($errors->has('body'))
                                    <span class="invalid-feedback">
                                        <strong>{{ $errors->first('body') }}</strong>
                                    </span>
                                @endif
                                <button type="submit" class="btn btn-success btn-block">
                                   发布问题
                                </button>
                            </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
        ue.ready(function() {
            ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
    </script>
@endsection
